"""
    案例：词云测试
    日期：2022-08
"""

import wordcloud
import jieba
import imageio.v2 as imageio

##########################################
f = open("../2021政府工作报告.txt", "r", encoding="utf-8")
txt = f.read()
f.close()

ls = jieba.lcut(txt)
for k in ls:
    if len(k) == 1:
        ls.remove(k)

# mask = imageio.imread("cloud.jpg")
mask = imageio.imread("../chapter05/china.jpeg")

# w = wordcloud.WordCloud(width=1000, font_path="msyh.ttc", height=700, mask=mask)
w = wordcloud.WordCloud(width=1000, font_path="/System/Library/fonts/PingFang.ttc", height=700, mask=mask, background_color="white")
w.generate(" ".join(ls))
w.to_file("result1.png")
